package org.qh.common.pay.configuration;


import jakarta.annotation.PostConstruct;
import lombok.extern.slf4j.Slf4j;
import org.qh.common.pay.factory.PayClientFactory;
import org.qh.common.pay.factory.impl.PayClientFactoryImpl;
import org.qh.common.pay.properties.PayProperties;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;

/**
 * 支付配置类
 */
@AutoConfiguration
@EnableConfigurationProperties(PayProperties.class)
@Slf4j
public class PayAutoConfiguration {

    @Bean(name = "payClientFactory")
    @ConditionalOnProperty(prefix = "pay", name = "enabled", havingValue = "true")
    public PayClientFactory payClientFactory() {
        return new PayClientFactoryImpl();
    }

    @PostConstruct
    public void init() {
        log.info("注册 【支付配置类】 成功 ！");
    }
}
